package com.kevin.Code.Bitwise;

/**
 * @author Vinlee Xiao
 * @Classname HammingDistance
 * @Description Leetcode 461. 汉明距离 简单题
 * @Date 2021/11/19 17:23
 * @Version 1.0
 */
public class HammingDistance {
    public int hammingDistance(int x, int y) {

        int res = x ^ y;

        int cnt = 0;
        while (res != 0) {
            res = res & (res - 1);
            cnt++;
        }
        return cnt;
    }
}
